import { createRouter, createWebHistory} from "vue-router";

import LoginVue from '@/views/Login.vue'
import LayoutVue from '@/views/Layout.vue'

import WorkCustomVue from "@/views/work/WorkCustom.vue"
import WorkEmployeVue from "@/views/work/WorkEmployee.vue"
import WorkOrderVue from "@/views/work/WorkOrder.vue"
import WorkUserOrderVue from "@/views/work/WorkUserOrder.vue"
import WorkServicesVue from "@/views/work/WorkServices.vue"
import WorkUserServicesVue from "@/views/work/WorkUserServices.vue"
import UserInfoVue from "@/views/user/UserInfo.vue"
import HomePageVue from "@/views/work/HomePage.vue"

//定义路由器
const routes = [
    {
        path: '/login', 
        component: LoginVue,
        meta:{requiresAuth: false}
    },
    {
        path: '/', 
        component: LayoutVue, 
        //重定向
        redirect:'/work/home', 
        meta:{requiresAuth: true},
        //子路由
        children:[
            {path: '/work/home', component: HomePageVue, meta:{requiresAuth: true}},
            {path: '/work/custom', component: WorkCustomVue, meta:{requiresAuth: true}},
            {path: '/work/services', component: WorkServicesVue, meta:{requiresAuth: true}},
            {path: '/work/userServices', component: WorkUserServicesVue, meta:{requiresAuth: true}},
            {path: '/work/order', component: WorkOrderVue, meta:{requiresAuth: true}},
            {path: '/work/userOrder', component: WorkUserOrderVue, meta:{requiresAuth: true}},
            {path: '/work/employee', component: WorkEmployeVue, meta:{requiresAuth: true}},
            {path: '/user/info', component: UserInfoVue, meta:{requiresAuth: true}}
    ]}
]


//创建路由器
const router = createRouter({
    history: createWebHistory(),
    routes: routes
});


export default router